var jettaGrayColor = '40 15 0 75, #2D3E4E'
function putJettaMobFormat(sizes) {
	$.each(sizes, function(size, i){
		// var logo = putVw30Logo('0 0 0 0, #fff')
		// var logo = putJettaHoriLogo('0 0 0 0, #fff')
		// var logo = putVwLogo('0 0 0 0, #fff')
		var logo = putJettaLogo()
		logo.setWidth('3cm')
		logo.toLeft('3cm', size)
		logo.toTop('3cm', size)
	})

	return sizes.map(function(size) {
		size.jUnit = 1000
		return size
	})
}

function putJettaPrintFormat(sizes, option) {
  if (!option.isPrint.on) { return }
	$.each(sizes, function(artboardSize){
		size = artboardSize.avoidance(option)
		var rule = getPrintRule(size)
		var segments = {XL: 1, S: 2, M: 3, L: 4,}
		var segment = segments[option.fmtSize.val]
		putPrintElements(size, rule, option, segment)
		_drawY(size, rule, option, '', segment)
	})
}

function putPrintElements(size, rule, option, segment) {
	var color = '0 0 0 0, #fff'
	var x1 = size.x1,
		y1 = size.y2 + size.height / segment,
		x2 = size.x1 + rule.J_Height * 2,
		y2 = y1 - size.y2,
		width = rule.J_Height * 2 + rule.T_Height * (100 / 106),
		vwHeight = rule.J_Height + rule.T_Height * (100 / 106) * (148 / 1000),
		jtHeight = y1 - size.y2 - vwHeight;

	if (segment === 1) {
		var logo = putJettaVLogo()
		logo.setHeight(rule.T_Height)
		logo.toLeft(rule.J_Height, size)
		logo.toTop(rule.J_Height, size)

		color = option.isLight.on ? '0 0 0 0, #fff' : null
		_putVwLogo(size, rule, option, color)
	} else {
		var pathItems = app.activeDocument.pathItems

		var blueRect = pathItems.rectangle(y1, x1, width, jtHeight)
		blueRect.fillColor = '90 55 0 0, #285AFF'.toAiColor()
		blueRect.stroked = false

		var grayRect = pathItems.rectangle(size.y2, x1, width, -vwHeight)
		grayRect.fillColor = jettaGrayColor.toAiColor()
		grayRect.stroked = false

		var logo = putJettaVLogo(color)
		logo.setHeight(rule.T_Height)
		logo.toLeft(rule.J_Height, size)
		logo.toCenter({height: Math.abs(y2 - vwHeight), y1: y1})
		logo.zOrder(ZOrderMethod.BRINGTOFRONT)

		_putVwLogo(size, rule, option)
	}

	_putSlogan(size, rule, color)

}

function putJettaOutdoorFormat(sizes, option) {
  if (!option.isOutdoor.on) { return }
	$.each(sizes, function(artboardSize){
		size = artboardSize.avoidance(option)
		var rule = getOutdoorRule(size)
    // alert('[Outdoor]:' + size.stringify())
		var ratios = [1/2,  1/1,   2/1,  3/1,  5/1,  6/1,  10/1]
		var index = ratios.stepIndex(size.ratio)
		switch (index) {
			case 0:
				putPrintElements(size, rule, option, 4)
				_drawY(size, rule, option, '', 4)
				break;
				
			case 1:
				putPrintElements(size, rule, option, 2)
				break;
		
			default:
				break;
		}

	})
}

function putJettaDigitalFormat(sizes, option) {
  var isMob = option.isMob.on
  var isWeb = option.isWeb.on
  if (!isMob && !isWeb) { return }

	$.each(sizes, function(artboardSize){
		size = artboardSize.avoidance(option)
		var rule = isWeb ? getWebRule(size) : getMobRule(size, option.fmtSize.val)
		var color = option.isLight.on ? '0 0 0 0, #fff' : null

		if(!option.isVLogo.on && !option.isHLogo.on) {
			if(size.ratio < 1) {
				var logo = putJettaVLogo(color)
				logo.setHeight(rule.T_Height)
			} else {
				var logo = putJettaHLogo(color)
				logo.setHeight(rule.H_Height)
			}
		}
		if (option.isVLogo.on && !option.isHLogo.on) {
			var logo = putJettaVLogo(color)
			logo.setHeight(rule.T_Height)
		}
		if (!option.isVLogo.on && option.isHLogo.on) {
			var logo = putJettaHLogo(color)
			logo.setHeight(rule.H_Height)
		}

		logo.toLeft(rule.J_Height, size)
		logo.toTop(rule.J_Height, size)


    _putVwLogo(size, rule, option, color)
    _putSlogan(size, rule, color)
		option.needY.on && _drawY(size, rule, option)
	})
}

function _putVwLogo(size, rule, option, color) {
		var vwLogo = option.need30.on ? putVw30Logo(color) : putVwLogo(color)
		vwLogo.setHeight(rule.V_Height)
		vwLogo.toRight(rule.J_Height, size)
		vwLogo.toBottom(rule.J_Height / 2, size)

		if (option.needQR.on) {
			var qrCode = putQrCode(color)
			var qrCodeWidth = rule.V_Height * (option.need30.on ? 3.04 : 1.294)
			qrCode.setHeight(rule.V_Height * 1.225)
			qrCode.toRight(qrCodeWidth + rule.J_Height + rule.V_Height * 0.2526, size)
			qrCode.toBottom(rule.J_Height / 2, size)
		}
}

function _putSlogan(size, rule, color) {
  var slogan = putSloganSVG(color)
  slogan.setWidth(rule.J_Height * 2.5)
  slogan.toLeft(rule.J_Height, size)
  slogan.toBottom(rule.J_Height * 0.4612 , size)
}

function _drawY(size, rule, option, color, segment) {
	var segments = {XL: 1, S: 2, M: 3, L: 4}
	var flip = segment || segments[option.fmtSize.val]
	if (segment === 1) { return }
	drawJettaY({
		left: size.x1,
		right: size.x1 + size.width,
		bottom: size.y2 + size.height / flip || 3,
		bleed: 0,
		height: rule.J_Height * 5,
		color: color || '0 95 75 0, 255 20 60',
	})
}


function getWebRule(size) {
	var T_type = (size.thin < 130) ? 'S' : (size.thin < 559 ? 'M' : 'L')
	var V_type = size.thin < 240 ? 'S' :  'L'
	var rule = {
		styles:  [4/3,  7/5,  3/2,  16/9,  2/1,  3/1,   4/1,  7/1,   8/1 ],

		S_TList: [0.56, 0.56, 0.56, 0.56,  0.56, 0.56,  0.56, 0.56,  0.56],
		M_TList: [0.21, 0.21, 0.21, 0.21,  0.28, 0.28,  0.42, 0.42,  0.56],
		L_TList: [0.21, 0.21, 0.21, 0.21,  0.28, 0.28,  0.42, 0.42,  0.56],

		S_HList: [0.40, 0.40, 0.40, 0.40,  0.40, 0.40,  0.40, 0.40,  0.40],
		M_HList: [0.15, 0.15, 0.15, 0.15,  0.20, 0.20,  0.30, 0.30,  0.40],
		L_HList: [0.15, 0.15, 0.15, 0.15,  0.20, 0.20,  0.30, 0.30,  0.40],

		S_VList: [0.57, 0.57, 0.57, 0.57,  0.57, 0.57,  0.57, 0.57,  0.57],
		L_VList: [0.43, 0.43, 0.43, 0.43,  0.43, 0.43,  0.43, 0.43,  0.43],
	}

	var index = rule.styles.stepIndex(size.style)
	var T_Height = size.thin * rule[T_type + '_TList'][index]
	var H_Height = size.thin * rule[T_type + '_HList'][index]
	var V_Height = T_Height  * rule[V_type + '_VList'][index]
	var J_Height = T_Height  / 2.65

	return { J_Height: J_Height, T_Height: T_Height, H_Height: H_Height, V_Height: V_Height }
}


function getMobRule(size, type) {
	var rule = {
		ratios:  [1/2,  1/3,  2/3,  3/4,   1/1,  4/3,  2/1,   3/1],
		S_TList: [0.14, 0.14, 0.14, 0.14,  0.08, 0.08, 0.08,  0.08],
		M_TList: [0.17, 0.17, 0.17, 0.17,  0.10, 0.10, 0.08,  0.08],
		L_TList: [0.17, 0.17, 0.17, 0.17,  0.08, 0.08, 0.08,  0.08],

		S_VList: [0.57, 0.57, 0.57, 0.43,  0.60, 0.60, 0.60,  0.60],
		M_VList: [0.43, 0.43, 0.43, 0.43,  0.60, 0.60, 0.60,  0.80],
		L_VList: [0.43, 0.43, 0.43, 0.43,  0.60, 0.60, 0.60,  0.80],
	}
  type = type === 'XL' ? 'L' : (type || 'L')
	var index = rule.ratios.stepIndex(size.ratio)
	var logoHeight = size.thin * rule[(type) + '_TList'][index]

	var T_Height = size.ratio < 1 ? logoHeight : logoHeight * (106 / 76)
	var H_Height = size.ratio >= 1 ? logoHeight : logoHeight * (76 / 106)
	var V_Height = logoHeight  * rule[(type) + '_VList'][index]
	var J_Height = T_Height / 2.65

	return { J_Height: J_Height, T_Height: T_Height, H_Height: H_Height, V_Height: V_Height }
}

function getPrintRule(size, type) {
  // var size = {width: 595.28 , height: 841.89}

  var width = new UnitValue(size.width, 'px').as('mm')
  var height = new UnitValue(size.height, 'px').as('mm')
  var area = width * height

  var A5 = 148 * 210
  var A4 = 210 * 297
  var A3 = 297 * 420
  var A2 = 420 * 594
  var A1 = 594 * 840
  var A0 = 840 * 1188

  var A50 = [148 * 210, 22]
  var A45 = [(A4 + A5) / 2, 32]
  var A35 = [(A3 + A4) / 2, 45]
  var A25 = [(A2 + A3) / 2, 64]
  var A15 = [(A1 + A2) / 2, 85]
  var A05 = [(A0 + A1) / 2, 120]

  var areaRange =  [A50[0], A45[0], A35[0], A25[0], A15[0], A05[0]]
  var logoRatios = [A50[1], A45[1], A35[1], A25[1], A15[1], A05[1]]
  var ratioIndex = areaRange.stepIndex(area)
  // alert(width + ' | ' + height + ' | ' +logoRatios[ratioIndex])

  var T_Height = new UnitValue(logoRatios[ratioIndex], 'mm').as('px')
  var H_Height = T_Height * (76 / 106)
  var V_Height = T_Height * 0.43
  var J_Height = T_Height / 2.65
	return { J_Height: J_Height, T_Height: T_Height, H_Height: H_Height, V_Height: V_Height }
}


function getOutdoorRule(size) {
	var rule = {
		ratios: [1/2,  1/1,   2/1,  3/1,  5/1,  6/1,  10/1],
		T_List: [1/5,  1/5,  0.17,  1/5, 0.34, 0.34,  0.34],
		// V_List: [0.43, 0.43, 0.43, 0.43, 0.43, 0.43,  0.43],
		Y_List: [5/1,  11/1,  9/1,  9/1, null, null,  11/1],
	}
	var index = rule.ratios.stepIndex(size.ratio)
	var T_Height = size.thin * rule.T_List[index]
	var H_Height = T_Height * (76 / 106)
  	var V_Height = T_Height * 0.43
  	var J_Height = T_Height / 2.65
	return { J_Height: J_Height, T_Height: T_Height, H_Height: H_Height, V_Height: V_Height }
}



function putJettaLogo(color) {
	var svgCode = '<svg version="1.1" id="jetta-logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 76" style="enable-background:new 0 0 100 76;" xml:space="preserve"> <path d="M28,71h9v5H22V52h14v5h-8v4.5h7v5h-7V71z M41,57h5v19h6V57h5v-5H41V57z M3.56,57H10v11c0,1.66-1.34,3-3,3H0.9 L0,76h9c3.87,0,7-3.13,7-7V52H4.43L3.56,57z M62,57h5v19h6V57h5v-5H62V57z M92.24,67L90,56.51L87.76,67H92.24z M93.22,72h-6.44 L86,76h-6l6-24h8l6,24h-6L93.22,72z M98.55,7.02C101.57,3.56,99.44,0,96.09,0H3.31C0.47,0-1.04,3.34,0.82,5.47L4.78,10h63.73 c0.95,0,1.45,1.11,0.83,1.82L55.83,27.27C54.31,29,52.11,30,49.81,30H23.39c-0.43,0-0.66,0.51-0.38,0.83l3.54,4.05 C29.4,38.13,33.51,40,37.84,40h25.04c4.33,0,8.44-1.87,11.29-5.12L98.55,7.02"/> </svg>'
	var svgGroup = insertSvg(svgCode)
	svgGroup.pageItems[0].pathItems[0].fillColor = (color || jettaGrayColor).toAiColor()
	return svgGroup
}

function putJettaHLogo(color) {
	var svgCode = '<svg version="1.1" id="jettaHoriLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve"> <path class="st0" d="M81.3,29.9L65.5,48c-1.9,2.1-4.5,3.3-7.3,3.3H41.9c-2.8,0-5.5-1.2-7.3-3.3l-2.3-2.6c-0.2-0.2,0-0.5,0.2-0.5 h17.2c1.5,0,2.9-0.6,3.9-1.8l8.8-10c0.4-0.5,0.1-1.2-0.5-1.2H20.4l-2.6-2.9c-1.2-1.4-0.2-3.6,1.6-3.6h60.3 C81.9,25.3,83.3,27.6,81.3,29.9z M18.2,68.5h4.6v-3.3h-4.6v-2.9h5.2v-3.3h-9.1v15.6h9.8v-3.3h-5.9V68.5z M26.7,62.4h3.3v12.4h3.9 V62.4h3.3v-3.3H26.7V62.4z M2.3,62.4h4.2v7.2c0,1.1-0.9,2-2,2h-4L0,74.7h5.9c2.5,0,4.6-2,4.6-4.6V59.1H2.9L2.3,62.4z M40.3,62.4h3.3 v12.4h3.9V62.4h3.3v-3.3H40.3V62.4z M61.1,59.1L65,74.7h-3.9l-0.5-2.6h-4.2l-0.5,2.6H52l3.9-15.6H61.1z M60,68.9L58.5,62l-1.5,6.8 H60z M72.3,66.4l-0.8,0.2v-2.2h0.8v-2.4h-0.8v-2.6h-2.4v2.6h-1.2v2.4h1.2v2.9l-1.2,0.3v2.6l1.2-0.3v2.3h-0.7l-0.4,2.4h3.5v-5.4 l0.8-0.2V66.4z M78.4,72.5h4l-0.4,2.2l-4,0c-1,0-1.9-0.3-2.8-0.7l-0.6-0.3l-0.2,1.1h-2.1l0.8-4.8h2.1l-0.2,1.4l0.6,0.4 c0.2,0.1,0.3,0.2,0.5,0.2v-0.5v-2.2l-2.8,0v-1.7H76v-0.6v-0.1h-2.4v-1.5H76V65v-0.6h-2.8v-1.7H76v-0.6h-2.8v-1.8H76v-1.1h2.3v1.1 h3.5v1.8h-3.5v0.6h3.2V65v0.1h0.7v1.5h-0.7v0.7v1.7h-3.2v0.8h3.2v1.8h-3.2L78.4,72.5C78.3,72.5,78.3,72.5,78.4,72.5z M78.3,65.2h1.1 V65v-0.7h-1.1V65V65.2z M78.3,66.7v0.1v0.7h1.1v-0.7v-0.1H78.3z M92.2,72.1c-1.4,0-2-0.3-3-0.9l-0.3-0.2v-5.9h-0.2h-2.2h-1.4v2.2 h1.4v2.7l-1.4,4.6h2.6l0.3-1.1l0.8,0.4c0.9,0.5,1.8,0.7,2.8,0.7l7.8,0l0.5-2.6H92.2z M88.6,64l-0.8-3.4h-2.5l0.8,3.4H88.6z M90.1,70.8h2.8l1.6-5.5l1.7,5.5H99L96.9,64H99v-2.4h-3.3h-0.2v-2.5h-2.4v2.5H93H90V64h2.2L90.1,70.8z"/> </svg> '
	var svgGroup = insertSvg(svgCode)
	svgGroup.pageItems[0].pathItems[0].fillColor = (color || jettaGrayColor).toAiColor()
	return svgGroup
}

function putJettaHorizontalLogo(color) {
	var svgCode = '<svg version="1.1" id="horizontalLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"	 y="0px" viewBox="0 0 258 40" style="enable-background:new 0 0 258 40;" xml:space="preserve"> <path d="M98.5,7L74.2,34.9c-2.8,3.3-7,5.1-11.3,5.1h-25c-4.3,0-8.4-1.9-11.3-5.1l-3.5-4C22.7,30.5,23,30,23.4,30h26.4 	c2.3,0,4.5-1,6-2.7l13.5-15.4c0.6-0.7,0.1-1.8-0.8-1.8H4.8l-4-4.5C-1,3.3,0.5,0,3.3,0h92.8C99.4,0,101.6,3.6,98.5,7z M132.2,22.5h7 	v-5h-7V13h8V8h-14v24h15v-5h-9V22.5z M145.2,13h5v19h6V13h5V8h-16V13z M107.8,13h6.4v11c0,1.7-1.3,3-3,3h-6.1l-0.9,5h9 	c3.9,0,7-3.1,7-7V8h-11.6L107.8,13z M166.2,13h5v19h6V13h5V8h-16V13z M198.2,8l6,24h-6l-0.8-4H191l-0.8,4h-6l6-24H198.2z M196.4,23 	l-2.2-10.5L192,23H196.4z M215.4,19.3l-1.3,0.4v-3.4h1.3v-3.6h-1.3V8.5h-3.6v4.1h-1.8v3.6h1.8v4.5l-1.8,0.5v4.1l1.8-0.5v3.5h-1.1 	l-0.7,3.6h5.4v-8.2l1.3-0.4V19.3z M224.8,28.5h6.1l-0.6,3.5l-6.2,0c-1.6,0-3-0.4-4.4-1.1l-1-0.5l-0.3,1.6h-3.2l1.3-7.4h3.2l-0.4,2.1 	l0.9,0.5c0.3,0.1,0.5,0.3,0.7,0.4v-0.8v-3.4l-4.3,0v-2.6h4.3v-1v-0.2h-3.7v-2.4h3.7v-0.2v-0.9h-4.3v-2.7h4.3v-1h-4.3V9.8h4.3V8h3.6 	v1.8h5.4v2.8h-5.4v1h4.9v3.6v0.2h1.1v2.4h-1.1v1.1v2.6h-4.9v1.2h4.9v2.8h-4.9v1.1C224.7,28.5,224.7,28.5,224.8,28.5z M224.6,17.4 	h1.7v-0.2v-1h-1.7v1V17.4z M224.6,19.7v0.2v1.1h1.7v-1.1v-0.2H224.6z M246,28c-2.2,0-3.1-0.5-4.6-1.3l-0.4-0.3v-9.1h-0.3h-3.4h-2.1 	v3.4h2.1V25l-2.1,7h3.9l0.5-1.8l1.2,0.6c1.4,0.7,2.8,1.1,4.4,1.1l12.1,0l0.7-4H246z M240.5,15.5l-1.3-5.2h-3.9l1.3,5.2H240.5z 	 M242.9,26.1h4.2l2.5-8.5l2.6,8.5h4.2l-3.3-10.6h3.3v-3.7h-5.1h-0.3V8h-3.6v3.8h-0.3h-4.5v3.7h3.4L242.9,26.1z"/> </svg> '
	var svgGroup = insertSvg(svgCode)
	svgGroup.pageItems[0].pathItems[0].fillColor = (color || jettaGrayColor).toAiColor()
	return svgGroup
}

function putJettaVLogo(color) {
	var svgCode = '<svg version="1.1" id="jettaVerticalLogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 106" style="enable-background:new 0 0 100 106;" xml:space="preserve"> <style type="text/css"> .st0{fill:#FFFFFF;} </style> <path class="st0" d="M0.8,5.5C-1,3.3,0.5,0,3.3,0h92.8c3.4,0,5.5,3.6,2.5,7L74.2,34.9c-2.8,3.3-7,5.1-11.3,5.1h-25 c-4.3,0-8.4-1.9-11.3-5.1l-3.5-4C22.7,30.5,23,30,23.4,30h26.4c2.3,0,4.5-1,6-2.7l13.5-15.4c0.6-0.7,0.1-1.8-0.8-1.8H4.8L0.8,5.5z M37,71h-9v-4.5h7v-5h-7V57h8v-5H22v24h15V71z M57,52H41v5h5v19h6V57h5V52z M3.6,57H10v11c0,1.7-1.3,3-3,3H0.9L0,76h9 c3.9,0,7-3.1,7-7V52H4.4L3.6,57z M62,57h5v19h6V57h5v-5H62V57z M100,76h-6l-0.8-4h-6.4L86,76h-6l6-24h8L100,76z M92.2,67L90,56.5 L87.8,67H92.2z M32.3,93.3l-1.3,0.4v-3.4h1.3v-3.6h-1.3v-4.1h-3.6v4.1h-1.8v3.6h1.8v4.5l-1.8,0.5v4.1l1.8-0.5v3.5h-1.1l-0.7,3.6h5.4 v-8.2l1.3-0.4V93.3z M41.7,102.5h6.1l-0.6,3.5l-6.2,0c-1.6,0-3-0.4-4.4-1.1l-1-0.5l-0.3,1.6h-3.2l1.3-7.4h3.2l-0.4,2.1l0.9,0.5 c0.3,0.1,0.5,0.3,0.7,0.4v-0.8v-3.4l-4.3,0v-2.6H38v-1v-0.2h-3.7v-2.4H38v-0.2v-0.9h-4.3v-2.7H38v-1h-4.3v-2.8H38V82h3.6v1.8h5.4 v2.8h-5.4v1h4.9v3.6v0.2h1.1v2.4h-1.1v1.1v2.6h-4.9v1.2h4.9v2.8h-4.9v1.1C41.6,102.5,41.7,102.5,41.7,102.5z M41.6,91.4h1.7v-0.2v-1 h-1.7v1V91.4z M41.6,93.7v0.2v1.1h1.7v-1.1v-0.2H41.6z M58.4,100.7l-0.4-0.3v-9.1h-0.3h-3.4h-2.1v3.4h2.1V99l-2.1,7H56l0.5-1.8 l1.2,0.6c1.4,0.7,2.8,1.1,4.4,1.1l12.1,0l0.7-4H63C60.8,102,59.9,101.5,58.4,100.7z M52.3,84.3l1.3,5.2h3.9l-1.3-5.2H52.3z M64.5,82 v3.8h-0.3h-4.5v3.7h3.4l-3.2,10.6h4.2l2.5-8.5l2.6,8.5h4.2l-3.3-10.6h3.3v-3.7h-5.1h-0.3V82H64.5z"/> </svg> '
	var svgGroup = insertSvg(svgCode)
	svgGroup.pageItems[0].pathItems[0].fillColor = (color || jettaGrayColor).toAiColor()
	return svgGroup
}

function putVw30Logo(color) {
	var svgCode = '''
	<svg version="1.1" id="Logo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 912 300" >
	<path  d="M289.29,270.31c-1.02,0-2.04,0-3.06,0l-10.45,28.99h6.18l1.85-5.86h5.48h5.35l1.92,5.86h6.18l-10.45-28.99 		C291.26,270.31,290.25,270.31,289.29,270.31z M289.29,288.22h-3.76l3.69-11.54l0.06,0.06l3.7,11.47H289.29z M70.66,223.16H0.96		v-12.55h69.71V223.16z M197.85,222.33h-25.04v-11.98h25.04V222.33z M130.56,185.12h31.22v10.77h-36.83 c-2.11,2.87-4.65,3.06-9.69,3.06h-5.92v-11.85h2.42c2.3,0,3.19-0.26,4.34-1.97l1.78-2.8h14.33L130.56,185.12z M85.95,218.77		l-4.84-13.19h13.57l2.68,6.37c0.7,1.98,2.24,2.42,4.27,2.42h3.44l0.07,10.71H96.6C91.25,225.07,87.93,224.11,85.95,218.77z M109.34,201.82h52.44v10.38h-52.44V201.82z M109.34,217.62h52.44v9.69l-26.83,16.88h26.83v10.77h-52.25v-9.75l28.48-17.01h-28.67		V217.62z M105.33,229.98l-4.21,16.51c-1.79,7.01-5.42,8.47-12.23,8.47h-7.07v-10.89h2.17c2.87,0,3.83-0.7,4.59-3.18l3.06-10.9 H105.33z M86.46,195.64L82,183.27h13.51l1.97,5.42c0.7,1.91,1.72,2.23,3.76,2.23h3.89v10.83h-6.5		C92.71,201.75,88.57,201.43,86.46,195.64z M382.77,244.06v10.89h-6.88c-5.86,0-7.52-1.08-9.05-7.52l-3.65-14.94l-4.7,15.2 c-1.98,6.37-3.63,7.26-9.75,7.26h-6.18v-10.89h1.08c2.16,0,2.67-1.08,3.51-3.76l8.35-26.57H369l-2.5,8.09h6.91l4.9,18.67		c0.7,2.68,1.27,3.57,3.44,3.57H382.77z M338.86,254.95h-6.88c-5.86,0-7.45-1.08-9.05-7.52l-3.61-14.96l-4.74,15.21 c-1.97,6.37-3.63,7.26-9.75,7.26h-6.12v-10.89h0.89c2.16,0,2.67-1.08,3.51-3.76l8.47-26.57h13.57l-2.52,8.09h6.85l4.9,18.67		c0.76,2.68,1.27,3.57,3.45,3.57h1.02V254.95z M309.23,210.99h-7.65v-10.77h2.22c2.16,0,3.38,0,5.16-3.75l6.12-13.19h52.44 l6.12,13.19c1.72,3.75,3.06,3.75,5.23,3.75h2.1v10.77h-7.14c-5.54,0-8.47-1.08-11.02-6.24l-4.71-9.44c-10.77,0-22.88,0-33.64,0		l-4.34,9.44C317.71,209.97,314.77,210.99,309.23,210.99z M212.63,254.95h-5.86v-10.89h2.04c3.63,0,5.29-1.21,7.32-4.33l20.72-34.85 h-29.82v-11.98h32.5v-10.45h15.3v10.45h32.63v11.98h-29.82l20.71,34.85c2.04,3.12,3.32,4.33,7.01,4.33h2.36v10.89h-5.86		c-7.9,0-11.21,0-15.61-7.45l-18.98-31.73l-18.99,31.73C223.78,254.95,220.47,254.95,212.63,254.95z M32.81,270.5 c-1.02,0-2.04,0-3.06,0L19.3,299.5h6.18l1.91-5.86h5.42h5.42l1.84,5.86h6.18L35.88,270.5C34.85,270.5,33.83,270.5,32.81,270.5z M32.81,288.41h-3.76l3.76-11.47l3.76,11.47H32.81z M0.82,270.5c4.97,0,9.94,0,14.91,0v5.48H6.56v6.05h9.18v5.48H6.56v11.98H0.82 V270.5z M87.55,284.01h11.22v4.97H87.55V284.01z M124.63,270.5h6.18l-10.45,28.99c-2.04,0-4.08,0-6.12,0L103.8,270.5h6.18 l7.33,22.62L124.63,270.5z M147.38,270.18c-9.31,0-13.77,6.69-13.77,14.79c0,8.22,4.46,14.91,13.77,14.91 c9.23,0,13.76-6.69,13.76-14.91C161.14,276.88,156.62,270.18,147.38,270.18z M147.38,295.04c-5.42,0-7.9-4.53-7.9-10.07 c0-5.48,2.48-9.94,7.9-9.94c5.35,0,7.84,4.46,7.84,9.94C155.22,290.51,152.73,295.04,147.38,295.04z M173.44,294.59h9.43v4.9H167.9 V270.5h5.54V294.59z M199.95,284.46l11.09,15.03h-7.34l-9.3-13.95v13.95h-5.54V270.5h5.54v13.13l9.37-13.13h6.75L199.95,284.46z M232.96,290.51c0.25,4.46-2.23,8.03-6.37,9.05c-3.13,0.7-7.33,0.51-10.58-0.19v-5.29c1.59,0.58,3.88,1.02,5.99,1.02 c2.8,0,5.03-1.15,5.03-3.82c0-5.54-11.85-3.38-12.17-12.55c-0.19-5.16,4.08-8.73,11.02-8.73c1.53,0,3.31,0.32,4.97,0.58v4.91v0.06 c-1.66-0.51-3.44-0.89-5.23-0.89c-3.18,0-4.84,1.46-4.84,3.57C220.79,283.31,232.45,281.34,232.96,290.51z M269.67,270.31h5.54 l-7.33,28.99c-2.23,0-4.52,0-6.75,0l-5.16-20.52l-5.16,20.52c-2.23,0-4.53,0-6.76,0l-7.33-28.99h5.54l5.22,21.47l5.55-21.47 c1.97,0,3.88,0,5.86,0l5.55,21.47L269.67,270.31z M323.76,284.08h5.61v14.34c-10.9,3.69-24.53,0.76-24.53-13.38 c0-9.05,6.18-15.17,16.18-15.17c2.87,0,5.74,0.45,8.22,1.21v5.48c-7.26-2.99-18.03-2.16-18.29,8.35c-0.19,7.58,5.99,11.15,12.8,9.3 V284.08z M336.37,270.31h15.74v4.72h-10.13v7.07h9.62v4.59h-9.62v7.84h10.13v4.78h-15.74V270.31z M376.96,270.31h5.23v28.99h-6.94 l-11.73-20.01v20.01h-5.29v-28.99h6.95l11.79,20.07V270.31z M77.42,270.5h5.54l-7.58,28.99c-2.17,0-4.33,0-6.44,0l-4.08-19.82 l-4.07,19.82h-1.21H55.5h-1.21L46.7,270.5h5.54l5.1,20.27l4.33-20.27c2.1,0,4.2,0,6.37,0l4.27,20.27L77.42,270.5z"/>
  	<path  d="M313.12,143.29c-37.34,0-67.98-30.84-67.98-68.19c0-8.39,1.47-16.36,4.3-23.81l39.76,80.04 c0.52,1.06,1.15,1.89,2.41,1.89c1.26,0,1.95-0.85,2.41-1.89l18.25-41.02c0.21-0.42,0.42-0.84,0.84-0.84s0.63,0.42,0.84,0.84 l18.25,41.02c0.46,1.03,1.15,1.89,2.41,1.89c1.26,0,1.89-0.84,2.41-1.89L376.8,51.3c2.83,7.45,4.3,15.42,4.3,23.81 C381.1,112.45,350.47,143.29,313.12,143.29 M313.12,59.69c-0.42,0-0.63-0.42-0.84-0.84l-21.4-48.04c6.92-2.52,14.48-3.88,22.24-3.88 s15.32,1.36,22.24,3.88l-21.4,48.04C313.75,59.27,313.54,59.69,313.12,59.69 M291.41,108.99c-0.42,0-0.63-0.42-0.84-0.84 l-34.62-69.76c6.19-9.44,14.48-17.41,24.44-22.97l24.86,55.39c0.42,1.05,1.05,1.26,1.89,1.26h11.96c0.84,0,1.47-0.21,1.89-1.26 l24.86-55.39c9.97,5.56,18.25,13.53,24.44,22.97l-34.62,69.76c-0.21,0.42-0.42,0.84-0.84,0.84c-0.42,0-0.63-0.42-0.84-0.84 l-13.01-29.79c-0.42-1.05-1.05-1.26-1.89-1.26h-11.96c-0.84,0-1.47,0.21-1.89,1.26l-13.01,29.79 C292.04,108.57,291.83,108.99,291.41,108.99 M313.12,150.22c41.54,0,75.11-33.57,75.11-75.11S354.66,0,313.12,0 c-41.54,0-75.11,33.57-75.11,75.11S271.58,150.22,313.12,150.22 M105.11,12.11c26.59,0,51.49,6.84,70.11,19.25 c17.73,11.82,27.5,27.25,27.5,43.46s-9.77,31.63-27.5,43.46c-18.62,12.41-43.52,19.25-70.11,19.25S53.62,130.69,35,118.28 C17.26,106.45,7.5,91.02,7.5,74.82S17.26,43.19,35,31.37C53.62,18.95,78.52,12.11,105.11,12.11 M105.11,4.75 C47.06,4.75,0,36.12,0,74.82s47.06,70.07,105.11,70.07c58.05,0,105.11-31.37,105.11-70.07S163.16,4.75,105.11,4.75L105.11,4.75z M87.65,100.98V88.27l-12.71,6.6h-33.4l2.91,7.11c1.22,2.79,4.19,4.63,7.26,4.63h25.09L87.65,100.98z M113.52,110.49V24.84h-6.48 L91.3,31.38c0,0-2.11,0.74-2.11,2.99s0,4.96,0,4.96h4.62c1.77,0,2.88,1.09,2.88,2.82l0,0.97v67.35c0,1.83-1.2,3.02-3.07,3.02h-5.98 v11.31h34.92V113.5h-5.98C114.72,113.5,113.52,112.32,113.52,110.49z M87.65,62.63V50.89H23.47L26.41,58 c1.22,2.79,4.16,4.63,7.24,4.63H87.65z M87.65,83.08V71.34H31.87l2.94,7.11c1.22,2.79,4.16,4.63,7.24,4.63H87.65z M168.17,83.08 c3.07,0,6.02-1.84,7.24-4.63l2.94-7.11h-55.77v11.74H168.17z M136.25,50.89v-3.26h-13.67v3.26h0v11.74h54 c3.07,0,6.02-1.84,7.24-4.63l2.94-7.11H136.25z M145.84,94.87L135,89.23h-12.43v11.74h10.65l10.84,5.63h14.45 c3.07,0,6.04-1.84,7.26-4.63l2.91-7.11H145.84z"/>
  	<rect  x="462.52" width="3" height="300"/>
	<path  d="M859.29,163.07c-2.18-1.95-5.11-2.93-8.78-2.93c-3.49,0-6.23,0.98-8.23,2.93c-1.95,2.05-2.93,4.49-2.93,7.32 c0,3.11,0.84,5.58,2.51,7.39c1.81,1.86,4.07,2.79,6.76,2.79c1.25,0,2.35-0.19,3.28-0.56l-6.9,10.11v0.42h6.62l8.3-12.76 c1.53-2.32,2.3-4.79,2.3-7.39C862.22,167.56,861.24,165.12,859.29,163.07 M845.56,170.39c0-1.67,0.42-2.9,1.25-3.7 c0.93-0.84,2.16-1.26,3.7-1.25c1.67,0,2.97,0.42,3.9,1.25c0.93,0.79,1.39,2.02,1.39,3.7c0,3.21-1.77,4.81-5.3,4.81 C847.21,175.2,845.56,173.6,845.56,170.39 M816.49,185.52v5.02h18.48v-5.02h-5.86v-24.75h-4.39l-7.6,2.58v5.02h0.7l5.3-1.67v18.82 H816.49 M782.81,105.28h-9.34v44.97h9.34V105.28 M831.54,105.28h-9.34v31.09l-19.38-31.09h-9.55v44.97h9.13v-31.16l19.38,31.16h9.76 V105.28 M849.11,127.66c0-4.88,1.02-8.65,3.07-11.29c2.09-2.84,5.09-4.25,8.99-4.25c3.44,0,6.93,0.7,10.46,2.09l2.37-7.18 c-4.14-1.91-8.41-2.86-12.83-2.86c-6.88,0-12.27,2.18-16.17,6.55c-3.67,4.18-5.51,9.83-5.51,16.94c0,7.2,1.84,12.85,5.51,16.94 c3.9,4.42,9.3,6.62,16.17,6.62c4.42,0,8.69-1.05,12.83-3.14l-2.37-7.18c-3.53,1.49-7.02,2.23-10.46,2.23c-3.9,0-6.9-1.32-8.99-3.97 C850.14,136.32,849.11,132.49,849.11,127.66 M894.22,168.37h0.7l5.23-1.67v18.82h-6.62v5.02H912v-5.02h-5.86v-24.75h-4.39 l-7.53,2.58V168.37 M885.09,163.07c-2.18-1.95-5.09-2.93-8.71-2.93c-3.53,0-6.27,0.98-8.23,2.93c-2,2.05-3,4.49-3,7.32 c0,3.11,0.84,5.58,2.51,7.39c1.86,1.86,4.16,2.79,6.9,2.79c1.21,0,2.28-0.19,3.21-0.56l-6.83,10.11v0.42h6.62l8.16-12.76 c1.58-2.32,2.37-4.79,2.37-7.39C888.09,167.56,887.09,165.12,885.09,163.07 M880.28,166.7c0.93,0.79,1.39,2.02,1.39,3.7 c0,3.21-1.77,4.81-5.3,4.81c-3.35,0-5.02-1.6-5.02-4.81c0-1.67,0.46-2.9,1.39-3.7c0.88-0.84,2.09-1.26,3.63-1.25 C878,165.44,879.3,165.86,880.28,166.7 M909.63,123.54h-18.75v-10.67h20.85v-7.6H881.6v44.97H912v-7.74h-21.12v-11.36h18.75V123.54 M753.74,123.82l-4.81-1.74c-3.02-0.84-4.53-2.42-4.53-4.74c0-3.67,2.3-5.51,6.9-5.51c3.25,0,6.74,1.02,10.46,3.07l2.72-7.53 c-4.14-2.14-8.53-3.21-13.18-3.21c-5.3,0-9.3,1.28-11.99,3.83c-2.84,2.56-4.25,5.93-4.25,10.11c0,5.9,3.56,10.02,10.67,12.34 l4.95,1.74c2.23,0.65,3.83,1.35,4.81,2.09c0.88,0.93,1.32,2.07,1.32,3.42c0,3.63-2.51,5.44-7.53,5.44c-1.81,0-4.02-0.33-6.62-0.98 c-2.23-0.6-4.04-1.39-5.44-2.37l-3.21,6.83c5.11,3.07,10.2,4.6,15.27,4.6c5.3,0,9.46-1.25,12.48-3.76 c2.97-2.56,4.46-6.04,4.46-10.46c0-3.39-1.07-6.16-3.21-8.3C761.24,126.89,758.15,125.26,753.74,123.82z M609.63,61.49 c-0.9-0.74-1.92-1.11-3.07-1.12h-61.84c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49c0,1.35,0.46,2.49,1.39,3.42 c0.98,0.98,2.14,1.46,3.49,1.46h53.75l-26.42,50.55c-0.52,1.02-0.68,2.07-0.49,3.14c0.21,1.11,0.72,2.04,1.53,2.79 c0.85,0.75,1.83,1.17,2.93,1.25c10.28,0.72,19.18,4.86,26.7,12.41c8.46,8.46,12.69,18.61,12.69,30.47c0,11.94-4.23,22.1-12.69,30.47 c-8.37,8.45-18.48,12.68-30.33,12.69c-3.33,0-6.54-0.32-9.62-0.98h0.07c-5.57-1.18-10.66-3.44-15.27-6.76 c-1.09-0.78-2.3-1.06-3.63-0.84c-1.32,0.21-2.39,0.86-3.21,1.95c-0.77,1.09-1.05,2.3-0.84,3.63c0.21,1.33,0.86,2.4,1.95,3.21 c5.71,4.11,12,6.9,18.89,8.37h0.07c3.71,0.79,7.56,1.18,11.57,1.19c14.55,0,26.96-5.18,37.23-15.55 c10.37-10.27,15.55-22.73,15.55-37.37c0-14.54-5.18-27-15.55-37.37c-7.46-7.5-16.03-12.27-25.73-14.29l26.98-51.59 c0.54-1.01,0.68-2.07,0.42-3.21C611.09,63.15,610.53,62.22,609.63,61.49 M703.61,6c-0.22-1.1-0.77-2.03-1.67-2.79 c-0.89-0.7-1.92-1.05-3.07-1.05H544.72c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49s0.46,2.49,1.39,3.42 c0.98,0.98,2.14,1.46,3.49,1.46h146.13l-35.28,68.32c-0.36,0.69-0.55,1.41-0.56,2.16c0,0.8,0.16,1.55,0.49,2.23 c0.26,0.54,0.63,1.05,1.12,1.53c23.42,23.42,35.14,51.61,35.14,84.57c0,33-11.72,61.12-35.14,84.36 c-23.24,23.42-51.39,35.14-84.43,35.14c-3.36-0.01-6.7-0.14-10.04-0.42l0,0c-5.62-0.4-11.08-1.19-16.38-2.37 c-1.31-0.26-2.54-0.03-3.7,0.7c-1.12,0.73-1.84,1.75-2.16,3.07c-0.27,1.31-0.03,2.52,0.7,3.63c0.73,1.17,1.75,1.89,3.07,2.16 c5.76,1.28,11.68,2.14,17.78,2.58c3.55,0.28,7.13,0.42,10.74,0.42c35.74,0,66.19-12.66,91.33-38c25.33-25.14,38-55.56,38-91.26 c0-34.57-11.9-64.29-35.7-89.17l37.37-72.3C703.73,8.24,703.87,7.14,703.61,6 M650.83,32.28c-0.88-0.7-1.88-1.04-3-1.05H544.72 c-1.35,0-2.51,0.46-3.49,1.39c-0.93,0.98-1.39,2.14-1.39,3.49c0,1.35,0.46,2.49,1.39,3.42c0.98,0.98,2.14,1.46,3.49,1.46h95.51 l-25.52,55.78c-0.49,1.1-0.58,2.22-0.28,3.35c0.36,1.17,1.04,2.08,2.02,2.72c4.54,3.01,8.87,6.56,12.97,10.67 c15.85,15.89,23.77,34.97,23.77,57.24c0,22.36-7.93,41.41-23.77,57.17c-15.76,15.85-34.79,23.77-57.1,23.77 c-3.4,0-6.75-0.18-10.04-0.56c-5.57-0.59-10.92-1.75-16.04-3.49c-1.28-0.4-2.53-0.31-3.76,0.28c-1.18,0.63-1.99,1.58-2.44,2.86 c-0.4,1.28-0.31,2.51,0.28,3.7c0.63,1.23,1.58,2.04,2.86,2.44c5.76,1.94,11.78,3.24,18.06,3.9c3.63,0.42,7.33,0.62,11.09,0.63 c25.01,0,46.34-8.88,64-26.63c17.76-17.66,26.63-39.02,26.63-64.07c0-24.96-8.88-46.34-26.63-64.14c-3.53-3.53-7.2-6.69-11.02-9.48 l26.91-58.98c0.5-1.03,0.61-2.1,0.35-3.21C652.3,33.86,651.72,32.98,650.83,32.28z M693.08,239.34c0.21,1.33,0.86,2.4,1.95,3.21 c19.05,13.75,40.92,20.63,65.61,20.64c31.42,0,58.22-11.11,80.39-33.33c6.23-6.18,11.58-12.73,16.04-19.66 c0.73-1.13,0.94-2.36,0.63-3.7c-0.26-1.29-0.96-2.31-2.09-3.07c-1.13-0.72-2.36-0.95-3.7-0.7c-1.3,0.31-2.32,1.03-3.07,2.16 c-4.09,6.36-9,12.38-14.71,18.06c-20.27,20.31-44.76,30.47-73.48,30.47c-22.54,0.01-42.5-6.27-59.89-18.82 c-1.09-0.78-2.3-1.06-3.63-0.84c-1.32,0.21-2.39,0.86-3.21,1.95C693.15,236.81,692.87,238.02,693.08,239.34 M705.7,202.32 c0.03,1.37,0.52,2.51,1.46,3.42c14.91,14.26,32.73,21.4,53.47,21.4c17.87-0.02,33.53-5.27,46.99-15.76 c1.06-0.83,1.67-1.92,1.81-3.28c0.18-1.31-0.14-2.49-0.98-3.56c-0.83-1.06-1.92-1.69-3.28-1.88c-1.3-0.14-2.49,0.21-3.56,1.05 c-11.74,9.13-25.4,13.69-40.99,13.66c-18.12,0-33.69-6.22-46.71-18.68c-0.96-0.91-2.12-1.35-3.49-1.32 c-1.32,0.04-2.46,0.55-3.42,1.53C706.11,199.88,705.67,201.01,705.7,202.32 M801.43,84.85c-0.32-1.3-1.07-2.3-2.23-3 c-11.46-6.63-24.31-9.95-38.55-9.97c-21.43,0-39.74,7.55-54.94,22.66c-3.58,3.64-6.74,7.43-9.48,11.36c-0.75,1.13-1,2.34-0.77,3.63 c0.25,1.35,0.93,2.39,2.02,3.14c1.13,0.8,2.34,1.08,3.63,0.84c1.34-0.25,2.39-0.95,3.14-2.09c2.42-3.45,5.21-6.78,8.37-9.97 c13.29-13.2,29.3-19.8,48.04-19.8c12.44-0.02,23.66,2.86,33.67,8.65c1.17,0.7,2.4,0.86,3.7,0.49c1.3-0.32,2.27-1.07,2.93-2.23 C801.64,87.38,801.8,86.14,801.43,84.85 M854.06,86.8c0.21-1.32-0.09-2.53-0.91-3.63c-3.56-4.82-7.6-9.49-12.13-14.01 c-22.17-22.17-48.97-33.26-80.39-33.26c-26.05,0.01-48.92,7.63-68.6,22.87c-1.06,0.87-1.69,1.96-1.88,3.28 c-0.14,1.35,0.21,2.56,1.05,3.63c0.83,1.06,1.9,1.67,3.21,1.81c1.35,0.19,2.56-0.13,3.63-0.98c17.96-13.91,38.83-20.86,62.61-20.85 c28.72,0,53.22,10.13,73.48,30.4c4.17,4.17,7.88,8.47,11.16,12.9c0.85,1.11,1.94,1.76,3.28,1.95c1.32,0.2,2.5-0.1,3.56-0.91 C853.22,89.2,853.87,88.13,854.06,86.8 M891.99,203.02c-1.22,0.49-2.11,1.35-2.65,2.58c-6.79,15.58-16.72,29.87-29.77,42.88 c-27.28,27.33-60.24,40.99-98.86,40.99c-29.8,0.02-56.23-8.06-79.27-24.26c-1.09-0.78-2.3-1.06-3.63-0.84 c-1.32,0.24-2.36,0.91-3.14,2.02c-0.78,1.1-1.06,2.31-0.84,3.63c0.23,1.32,0.88,2.36,1.95,3.14c24.69,17.36,53,26.05,84.92,26.07 c41.32,0,76.57-14.62,105.76-43.85c13.95-13.91,24.55-29.2,31.79-45.87c0.54-1.24,0.56-2.49,0.07-3.76 c-0.49-1.23-1.35-2.11-2.58-2.65C894.52,202.55,893.26,202.53,891.99,203.02 M711.7,16.52c1.2,0.63,2.43,0.73,3.7,0.28 c14.12-4.7,29.22-7.05,45.32-7.04c38.62,0,71.58,13.64,98.86,40.92c11.54,11.53,20.65,24.05,27.33,37.58 c0.62,1.21,1.55,2.02,2.79,2.44c1.3,0.45,2.55,0.35,3.76-0.28c1.21-0.57,2.03-1.5,2.44-2.79c0.45-1.25,0.35-2.48-0.28-3.7 c-7.12-14.46-16.83-27.84-29.14-40.16C837.28,14.59,802.03,0,760.71,0c-17.18,0-33.31,2.51-48.38,7.53 c-1.27,0.46-2.23,1.3-2.86,2.51c-0.59,1.2-0.68,2.43-0.28,3.7C709.65,15.01,710.48,15.94,711.7,16.52z"/> </svg>
  	'''

	var svgGroup = insertSvg(svgCode)
	var pageItems = svgGroup.pageItems
	pageItems[0].pathItems[0].fillColor = (color || '31 91 80 0, 181 63 68').toAiColor() // 30
	pageItems[1].fillColor = (color || '0 0 0 65, 125 125 125').toAiColor() // line
	pageItems[2].pathItems[0].fillColor = (color || '100 65 0 45, 0 30 80').toAiColor() // vw
	pageItems[3].pathItems[0].fillColor = (color || '0 0 0 65, 125 125 125').toAiColor() // type
	return svgGroup
}

function putVwLogo(color) {
	var svgCode = '''
	<svg version="1.1" id="Vwlogo" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 388.2 300" style="enable-background:new 0 0 388.2 300;" xml:space="preserve">
	<path class="st0" d="M289.3,270.3c-1,0-2,0-3.1,0l-10.5,29h6.2l1.9-5.9h5.5h5.4l1.9,5.9h6.2l-10.5-29 C291.3,270.3,290.2,270.3,289.3,270.3z M289.3,288.2h-3.8l3.7-11.5l0.1,0.1l3.7,11.5L289.3,288.2L289.3,288.2z M70.7,223.2H1v-12.6 h69.7L70.7,223.2L70.7,223.2z M197.8,222.3h-25v-12h25V222.3z M130.6,185.1h31.2v10.8h-36.8c-2.1,2.9-4.7,3.1-9.7,3.1h-5.9v-11.9 h2.4c2.3,0,3.2-0.3,4.3-2l1.8-2.8h14.3L130.6,185.1z M85.9,218.8l-4.8-13.2h13.6l2.7,6.4c0.7,2,2.2,2.4,4.3,2.4h3.4l0.1,10.7h-8.5 C91.2,225.1,87.9,224.1,85.9,218.8z M109.3,201.8h52.4v10.4h-52.4V201.8z M109.3,217.6h52.4v9.7l-26.8,16.9h26.8V255h-52.2v-9.8 l28.5-17h-28.7V217.6z M105.3,230l-4.2,16.5c-1.8,7-5.4,8.5-12.2,8.5h-7.1v-10.9H84c2.9,0,3.8-0.7,4.6-3.2l3.1-10.9L105.3,230 L105.3,230z M86.5,195.6L82,183.3h13.5l2,5.4c0.7,1.9,1.7,2.2,3.8,2.2h3.9v10.8h-6.5C92.7,201.7,88.6,201.4,86.5,195.6z M382.8,244.1v10.9h-6.9c-5.9,0-7.5-1.1-9-7.5l-3.6-14.9l-4.7,15.2c-2,6.4-3.6,7.3-9.7,7.3h-6.2v-10.9h1.1c2.2,0,2.7-1.1,3.5-3.8 l8.4-26.6H369l-2.5,8.1h6.9l4.9,18.7c0.7,2.7,1.3,3.6,3.4,3.6L382.8,244.1L382.8,244.1z M338.9,254.9H332c-5.9,0-7.5-1.1-9-7.5 l-3.6-15l-4.7,15.2c-2,6.4-3.6,7.3-9.8,7.3h-6.1V244h0.9c2.2,0,2.7-1.1,3.5-3.8l8.5-26.6h13.6l-2.5,8.1h6.9l4.9,18.7 c0.8,2.7,1.3,3.6,3.5,3.6h1L338.9,254.9L338.9,254.9z M309.2,211h-7.6v-10.8h2.2c2.2,0,3.4,0,5.2-3.8l6.1-13.2h52.4l6.1,13.2 c1.7,3.8,3.1,3.8,5.2,3.8h2.1V211h-7.1c-5.5,0-8.5-1.1-11-6.2l-4.7-9.4c-10.8,0-22.9,0-33.6,0l-4.3,9.4 C317.7,210,314.8,211,309.2,211z M212.6,254.9h-5.9v-10.9h2c3.6,0,5.3-1.2,7.3-4.3l20.7-34.8H207v-12h32.5v-10.4h15.3v10.4h32.6v12 h-29.8l20.7,34.8c2,3.1,3.3,4.3,7,4.3h2.4v10.9h-5.9c-7.9,0-11.2,0-15.6-7.4l-19-31.7l-19,31.7C223.8,254.9,220.5,254.9,212.6,254.9 z M32.8,270.5c-1,0-2,0-3.1,0l-10.5,29h6.2l1.9-5.9h5.4h5.4l1.8,5.9h6.2l-10.4-29C34.8,270.5,33.8,270.5,32.8,270.5z M32.8,288.4H29 l3.8-11.5l3.8,11.5H32.8z M0.8,270.5c5,0,9.9,0,14.9,0v5.5H6.6v6h9.2v5.5H6.6v12H0.8V270.5z M87.5,284h11.2v5H87.5V284z M124.6,270.5h6.2l-10.4,29c-2,0-4.1,0-6.1,0l-10.4-29h6.2l7.3,22.6L124.6,270.5z M147.4,270.2c-9.3,0-13.8,6.7-13.8,14.8 c0,8.2,4.5,14.9,13.8,14.9c9.2,0,13.8-6.7,13.8-14.9C161.1,276.9,156.6,270.2,147.4,270.2z M147.4,295c-5.4,0-7.9-4.5-7.9-10.1 c0-5.5,2.5-9.9,7.9-9.9c5.4,0,7.8,4.5,7.8,9.9C155.2,290.5,152.7,295,147.4,295z M173.4,294.6h9.4v4.9h-15v-29h5.5L173.4,294.6 L173.4,294.6z M199.9,284.5l11.1,15h-7.3l-9.3-14v14h-5.5v-29h5.5v13.1l9.4-13.1h6.8L199.9,284.5z M233,290.5c0.2,4.5-2.2,8-6.4,9 c-3.1,0.7-7.3,0.5-10.6-0.2v-5.3c1.6,0.6,3.9,1,6,1c2.8,0,5-1.1,5-3.8c0-5.5-11.9-3.4-12.2-12.5c-0.2-5.2,4.1-8.7,11-8.7 c1.5,0,3.3,0.3,5,0.6v4.9v0.1c-1.7-0.5-3.4-0.9-5.2-0.9c-3.2,0-4.8,1.5-4.8,3.6C220.8,283.3,232.4,281.3,233,290.5z M269.7,270.3 h5.5l-7.3,29c-2.2,0-4.5,0-6.8,0l-5.2-20.5l-5.2,20.5c-2.2,0-4.5,0-6.8,0l-7.3-29h5.5l5.2,21.5l5.6-21.5c2,0,3.9,0,5.9,0l5.5,21.5 L269.7,270.3z M323.8,284.1h5.6v14.3c-10.9,3.7-24.5,0.8-24.5-13.4c0-9,6.2-15.2,16.2-15.2c2.9,0,5.7,0.5,8.2,1.2v5.5 c-7.3-3-18-2.2-18.3,8.4c-0.2,7.6,6,11.1,12.8,9.3L323.8,284.1L323.8,284.1z M336.4,270.3h15.7v4.7H342v7.1h9.6v4.6H342v7.8h10.1 v4.8h-15.7V270.3z M377,270.3h5.2v29h-6.9l-11.7-20v20h-5.3v-29h7l11.8,20.1L377,270.3L377,270.3z M77.4,270.5H83l-7.6,29 c-2.2,0-4.3,0-6.4,0l-4.1-19.8l-4.1,19.8h-1.2h-4.1h-1.2l-7.6-29h5.5l5.1,20.3l4.3-20.3c2.1,0,4.2,0,6.4,0l4.3,20.3L77.4,270.5z"/>
	<path class="st1" d="M313.1,143.3c-37.3,0-68-30.8-68-68.2c0-8.4,1.5-16.4,4.3-23.8l39.8,80c0.5,1.1,1.1,1.9,2.4,1.9s2-0.9,2.4-1.9 l18.2-41c0.2-0.4,0.4-0.8,0.8-0.8s0.6,0.4,0.8,0.8l18.2,41c0.5,1,1.1,1.9,2.4,1.9s1.9-0.8,2.4-1.9l39.8-80 c2.8,7.4,4.3,15.4,4.3,23.8C381.1,112.4,350.5,143.3,313.1,143.3 M313.1,59.7c-0.4,0-0.6-0.4-0.8-0.8l-21.4-48 c6.9-2.5,14.5-3.9,22.2-3.9s15.3,1.4,22.2,3.9l-21.4,48C313.7,59.3,313.5,59.7,313.1,59.7 M291.4,109c-0.4,0-0.6-0.4-0.8-0.8 l-34.6-69.8c6.2-9.4,14.5-17.4,24.4-23l24.9,55.4c0.4,1.1,1,1.3,1.9,1.3h12c0.8,0,1.5-0.2,1.9-1.3l24.9-55.4 c10,5.6,18.2,13.5,24.4,23l-34.6,69.8c-0.2,0.4-0.4,0.8-0.8,0.8c-0.4,0-0.6-0.4-0.8-0.8l-13-29.8c-0.4-1.1-1-1.3-1.9-1.3h-12 c-0.8,0-1.5,0.2-1.9,1.3l-13,29.8C292,108.6,291.8,109,291.4,109 M313.1,150.2c41.5,0,75.1-33.6,75.1-75.1S354.7,0,313.1,0 S238,33.6,238,75.1S271.6,150.2,313.1,150.2 M105.1,12.1c26.6,0,51.5,6.8,70.1,19.2c17.7,11.8,27.5,27.2,27.5,43.5 s-9.8,31.6-27.5,43.5c-18.6,12.4-43.5,19.2-70.1,19.2s-51.5-6.8-70.1-19.2C17.3,106.4,7.5,91,7.5,74.8S17.3,43.2,35,31.4 C53.6,18.9,78.5,12.1,105.1,12.1 M105.1,4.7C47.1,4.7,0,36.1,0,74.8s47.1,70.1,105.1,70.1s105.1-31.4,105.1-70.1 S163.2,4.7,105.1,4.7L105.1,4.7z M87.6,101V88.3l-12.7,6.6H41.5l2.9,7.1c1.2,2.8,4.2,4.6,7.3,4.6h25.1L87.6,101z M113.5,110.5V24.8 H107l-15.7,6.5c0,0-2.1,0.7-2.1,3s0,5,0,5h4.6c1.8,0,2.9,1.1,2.9,2.8v1v67.3c0,1.8-1.2,3-3.1,3h-6v11.3h34.9v-11.3h-6 C114.7,113.5,113.5,112.3,113.5,110.5z M87.6,62.6V50.9H23.5l2.9,7.1c1.2,2.8,4.2,4.6,7.2,4.6H87.6z M87.6,83.1V71.3H31.9l2.9,7.1 c1.2,2.8,4.2,4.6,7.2,4.6C42,83.1,87.6,83.1,87.6,83.1z M168.2,83.1c3.1,0,6-1.8,7.2-4.6l2.9-7.1h-55.8v11.7H168.2z M136.2,50.9 v-3.3h-13.7v3.3l0,0v11.7h54c3.1,0,6-1.8,7.2-4.6l2.9-7.1C186.8,50.9,136.2,50.9,136.2,50.9z M145.8,94.9L135,89.2h-12.4V101h10.7 l10.8,5.6h14.4c3.1,0,6-1.8,7.3-4.6l2.9-7.1L145.8,94.9L145.8,94.9z"/>
	</svg>
	'''

	var svgGroup = insertSvg(svgCode)
	var pageItems = svgGroup.pageItems
	var vwColorString = color || '100 65 0 45, 0 30 80'
	var typeColorString = color || '0 0 0 65, 125 125 125'
	pageItems[0].pathItems[0].fillColor = vwColorString.toAiColor() // vw
	pageItems[1].pathItems[0].fillColor = typeColorString.toAiColor() // type
	return svgGroup
}

function putSloganSVG(color) {
	var svgCode = '<svg version="1.1" id="slogan" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 82.1" style="enable-background:new 0 0 500 82.1;" xml:space="preserve"> <path d="M0,63.4c3.4-4.7,6.1-9.8,8.1-15.3c2-5.7,3.3-11.5,4.1-17.6H3.1v-7.5h16.2v7.5c-0.5,3.7-1.3,7.3-2,11 c-0.7,3.3-1.6,6.5-2.7,9.7c-2.3,6.2-5.3,12-8.9,17.5L0,63.4z M26.8,38.5V33h-5.9v-6.6h5.9V21L39,13.3H9.1V5.8h43.1v6.9l-18,11.6v2 h5.7V33h-5.7v5.6h7.1V45h-7.1v6h10.4v6.5H34.1v5.8c0,1.6-0.2,3.2-0.6,4.9c-0.2,0.9-0.6,1.6-1.2,2.4c-0.9,0.9-1.8,1.4-2.9,1.7 c-1.5,0.3-3.1,0.5-4.6,0.5h-6.7l-1.3-6.9h5.9c0.7,0,1.5-0.1,2.3-0.2c0.4-0.1,0.7-0.2,0.9-0.5c0.4-0.4,0.5-0.8,0.6-1.3 c0.1-0.9,0.2-1.6,0.2-2.5v-3.8H16.5v-6.5h10.3v-6h-7.2v-6.5H26.8z M47.2,21.2c0.2,3.1,0.5,6.3,1,9.3c2.4-2.4,4.9-4.9,7.1-7.7 l5.2,5.3c-3.5,3.7-7.2,7.2-10.9,10.7c0.9,4.4,2.3,8.6,4.2,12.7c2,4.2,4.6,8.1,7.6,11.5l-5.7,5.6c-4.4-5.4-7.8-11.3-10-17.8 c-1.4-4.2-2.5-8.5-3.4-12.9c-0.9-5.3-1.6-10.7-2-16.1L47.2,21.2z M93.3,13V2.9h7.7V72h-7.7V58H75.4v-7.5h17.8V38.8h-15v-7.4h15V20.4 H77.2V13H93.3z M114.6,2.4V13h16.2v7.4h-16.2v11.1h15.1v7.4h-15.1v11.6h17.9V58h-17.9v14.4h-7.5v-70H114.6z M146.7,67.9 c2.1-2.4,4.1-4.9,5.8-7.7c1.1-1.8,2-3.8,2.7-5.7c0.9-2.9,1.6-5.9,1.8-8.9c0.3-4.2,0.5-8.4,0.5-12.6V6h35.7v52.7 c-0.1,0.9-0.1,1.6,0,2.4c0,0.5,0.1,0.9,0.3,1.3c0.2,0.2,0.4,0.4,0.6,0.5c0.5,0.1,1,0.2,1.6,0.1h1c0.8,0.1,1.5-0.1,2-0.6 c0.2-0.4,0.3-0.8,0.4-1.2l0.2-2l0.2-13l7.3,1.5l-0.5,14.8c-0.1,1.5-0.4,2.9-0.8,4.3c-0.2,0.8-0.6,1.5-1.2,2.1 c-0.7,0.7-1.5,1.3-2.5,1.6c-1.3,0.3-2.5,0.5-3.8,0.5h-5.3c-1.3,0-2.6-0.2-3.8-0.5c-1-0.4-1.8-0.9-2.5-1.8c-0.7-1-1.2-2.2-1.4-3.5 c-0.2-1.3-0.4-2.5-0.3-3.8V44.2l-5.3,4.9c-4.5-6.3-9.1-12.5-13.8-18.7V33c0,4.7-0.2,9.4-0.6,14c-0.4,3.5-1.1,7.1-2.1,10.5 c-0.9,2.3-1.9,4.5-3.1,6.7c-2,3.1-4.2,6-6.6,8.9L146.7,67.9z M165.6,28.4l4.8-4.5l14.4,18.4V14.1h-19.1V28.4z M230.7,77.3 c0.7-0.3,1.4-0.8,2-1.3c0.6-0.7,1.2-1.5,1.6-2.4c0.9-1.7,1.5-3.6,1.6-5.6H231V54.8h10.4v12.8c-0.1,3.5-1.1,6.7-3.2,9.4 c-2,2.4-4.5,4.2-7.4,5.2V77.3z M292.1,65.6c2.9-4.9,5.2-10,6.7-15.5c0.7-3.2,1.3-6.4,1.6-9.7c0.3-4,0.5-8.1,0.5-12.1V9.3h21.5 l-2.8-6.7l7.8-2.6l3.9,9.3h19v24h-41.3c-0.1,6.2-0.8,12.2-2.1,18.3c-1.7,6.6-4.2,12.9-7.5,18.8L292.1,65.6z M348.9,41.3v31.2h-8.1 v-3.9h-24.3v3.9h-7.9V41.3H348.9z M308.9,26.1h33.3v-9.8h-33.3V26.1z M316.5,61.7h24.3V48.4h-24.3V61.7z M365.9,64.9 c3.1-5.3,5.5-10.7,7.3-16.6l6.2,2.3c-2.1,6.1-4.7,12-7.8,17.6L365.9,64.9z M376.2,15.8h-6.6V9.2h10.9l-2.4-6.5l6.9-2.1 c1.1,2.9,2.1,5.7,3.1,8.6h9.5v6.6h-7l4,1.3c-1.1,3.2-2.3,6.4-3.5,9.6h7.2v6.7h-11.1v7.2h10.5v6.8h-10.5v4.2l4.7-3.2 c1.9,3.1,3.8,6.3,5.6,9.4c0.9-3.1,1.4-6.4,1.6-9.6c0.4-4.9,0.5-10,0.5-15V8.9c4.2-0.5,8.5-1.3,12.6-2.3c3.3-0.8,6.5-1.9,9.6-3.2 l2.4,7.2c-5.6,2.5-11.5,4.2-17.5,5v11.8h18.7v7.2h-5.6v37.2h-7.3V34.7h-5.7v0.1c0,4.5-0.2,8.9-0.4,13.3c-0.2,3.4-0.6,6.7-1.3,10.1 c-1.3,5.4-3.3,10.6-6.2,15.4l-7.2-3.5c1.7-2.7,3.2-5.6,4.5-8.7l-3.1,2.3c-2-3.6-3.9-7.2-6-10.7v11.3c0,1.3-0.2,2.6-0.5,3.9 c-0.2,0.9-0.7,1.7-1.4,2.4c-0.5,0.5-1.3,0.8-2,0.9c-1.3,0.3-2.6,0.5-3.9,0.5h-3.9l-1.4-7.1h3.2c2.4,0,3.2-1.3,2.7-3.9V47.4h-11.5 v-6.8h11.5v-7.2H368v-6.7h7.7l-3.7-9.3L376.2,15.8z M384.2,26.7c1.4-3.5,2.7-7.2,4.1-10.9h-10c1.3,3.1,2.7,6.3,3.8,9.5l-3.5,1.4 H384.2z M446.9,20.9V1.8h7.1v19.1h4.6v7.3H454v22.8c1.7-0.6,3.5-1.3,5.3-2.1l1,7.5c-6.3,2.3-12.5,4.7-18.6,7.2l-1.5-7.5 c2.2-0.7,4.4-1.6,6.7-2.4V28.2h-5.3v-7.3H446.9z M454,67.2c1.8-0.6,3.6-1.3,5.4-2.2c1.8-0.8,3.4-1.8,4.9-3.1c2.2-2,3.4-4.6,3.5-7.7 v-0.1h-6.7V30h33.7v24.2h-8.5v7.6c-0.1,0.6,0,1.3,0.1,1.8c0,0.4,0.1,0.8,0.3,1c0.5,0.5,1.2,0.7,1.9,0.6h2.4c0.7,0.1,1.4-0.2,2-0.6 c0.2-0.2,0.3-0.5,0.4-0.9l0.2-1.8l0.2-7.5l6.2,1.3l-0.5,8.3c-0.1,1.3-0.3,2.5-0.6,3.8c-0.2,0.9-0.6,1.6-1.3,2.3 c-0.5,0.4-1.1,0.7-1.7,0.9c-1.2,0.2-2.4,0.4-3.6,0.4h-6.6c-1,0-2-0.2-3.1-0.5c-0.8-0.2-1.5-0.7-2-1.3c-0.4-0.5-0.6-1.2-0.9-1.8 c-0.3-1.2-0.5-2.4-0.4-3.5v-10h-4.2c-0.1,2-0.4,3.9-0.9,5.8c-0.7,2.1-1.8,4.1-3.3,5.7c-1.6,1.6-3.5,3.1-5.6,4.3 c-2.6,1.3-5.2,2.6-7.8,3.7L454,67.2z M474.6,7.8l-2.1-5.6l7.7-2c0.9,2.6,1.9,5.1,2.7,7.7h13.8v5.8h-9.5l3.3,1.6 c-0.8,1.7-1.6,3.4-2.4,5.1h10.7v5.9h-38.8v-5.9h8.5l-2.6-5.3l2.7-1.3h-8.3V7.8H474.6z M468,39.4h19.9v-3.5H468V39.4z M487.8,48.5V45 H468v3.5H487.8z M472.9,13.6l3.3,6.7h4.4c1.1-2.1,2.1-4.4,3.1-6.7H472.9z"/> </svg> '
	var svgGroup = insertSvg(svgCode)
	svgGroup.pageItems[0].pathItems[0].fillColor = (color || jettaGrayColor).toAiColor()
	return svgGroup
}

function putQrCode(isLight, color) {
	var svgCode = '''
	<svg version="1.1" id="JettaQR" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1228.2" style="enable-background:new 0 0 1000 1228.2;" xml:space="preserve">
	<rect width="1000" height="1000"/>
	<path d="M590,26v26h-26V26H590z M718,26h-52v26h52V26z M974,26v180H794V26H974z M948,52H820v26v24v26v26v26h128v-24v-26v-26V78V52z M590,78h26V52h-26V78z M642,52V26h-26v26h24v26h26V52H642z M154,128v-26V78H76v24v26v26h78V128z M334,102h76v26h-76v26h-26v26h26 v26h26v-26v-26h24v26v26h-24v24h24v26h-24v26h26v-26h50v-26h-26v-24v-26v-26h26v-26v-26h26V78V52h50V26H410v26h-50V26h-26v26h-26V26 h-26v26v26h52V102z M564,102h-26v26h26v-24h26V78h-26V102z M488,128v-24h26V78h-26v24h-26v26H488z M770,102V78V52h-26v26v24v26h26 V102z M692,154h26v-26v-26V78h-52v24v26h-24v-26h-26v26h24v26h26v26h26V154z M924,78h-78v76h78V78z M256,154v-26h26v-26V78h-26V52 h-26v26v24v26v26v26v26h26v-26V154z M206,206H26V26h180v154V206z M180,52H52v128h128V52z M308,180h-26v26h26V180z M590,154v26v26h26 v-26v-26v-26h-26V154z M666,230v-24v-26h-26v26v24v26h26V230z M692,230h78v-24v-26v-26h-26v26v26h-26v-26h-26v26V230z M102,256v-26 H76v26H102z M360,230h-26v26h26V230z M796,256v-26h-26v26H796z M154,308h-26v26h52v-26h26v-26h-26v-26h26v26h24v-26h26v26h-26v26h52 v-26h26v26h52v-26h-26v-26h-52v-26v-24h-26v24H154v26h-26v26h26V308z M718,308h26v-26v-26h-26v26V308z M386,334.1v-26h-26v26H386z M410,308v26h26v-26H410z M692,334.1h26v-26h-26V334.1z M950,256h24v26v26v26v26v24v26h-26v-26v-24h-24v-26h24v-26h-24v-26h24v-26 h-50v26v26v26v26h-52v-26h26v-26h-26v26h-26v-26h-52v-26h52v-26v-26h130V256z M872,256h-26v26h26V256z M206,334.1h-26v26h26V334.1z M230,334.1v26h26v-26H230z M282,360.1h-26v24h52v-24h52v-26h-78V360.1z M436,334.1v26h52v-26H436z M820,360.1h26v20h-26v26h-26v26 h-26v-26h-26v26h26v26h26v-26h26v26h24v26v26h52v26v26h26v-26v-24h-24v-24v-26h26v26v22h24v-26v-22h-24v-26h26v22h24v26v26v26h-26 v26h26v26v26h-26v-26h-76v-26v-26h-52v26h26v26h26v26h-26v26v26v26v26h-26v24h50v26h26v26h26v26h-26v26h-26v26h52v26h-26v26h-50v26 h-26v24h-26v-26h26v-24h24v-26v-26h-76v26h26v26h-26v26v26h-52v-26h-24v-26h24v-26h26v-26h-52v-26v-26h-74v-24h-26v24h-26v-26h26 v-24h26v24h24v-24v-26h-24v-26h24v-26v-26v-24h26v24v26h26v26h24v-26v-26h26v26h52v24h26v-24v-26h-26v-26h26v-20v-26h-52v-26h-24v22 v26h26v26h-78v-26h26v-26v-26h24v-22h-26v-26h-26v-26h26v-26v-26h-26v-26h26v-26v-26h52v-26h52V360.1z M742,924.1h-24v26h24V924.1z M742,744.1h-52v-26h-24v26v26h26v24v26h50v-24h-26v-26h26V744.1z M768,744.1h26v-26h-26V744.1z M770,769.1v77h76v-77H770z M768,514.1h52v-26h-52V514.1z M898,384.1h-52v26v26h52v-26h26v-26v-24h-26V384.1z M538,436.1h26v-26h-26V436.1z M462,462.1h-26v26 h26V462.1z M590,462.1h-26v26h26V462.1z M102,512.1h26v26v26h26v-26h26v-26h26v-24h-26v-26h26v-26h-26v-26h-26v-24h26v24h26v-26h-26 v-24h-26v24h-26v-24v-26h-26v26v24v26h26v26h26v26h-52v-26v-26H76v-26H52v-24v-26v-26h24v26h26v-26h26v-26H26v26v26v26v24v26v26h26 v26h24v26v24v26v26h26v-26V512.1z M360,512.1h-26v26h26V512.1z M616,538.1h-52v-26h52v-24h24v-24h-48v-26v-26v-26h-26v-26h-26v26 h-26v26v26v24h24v26h26v24h-52v-24v-24h-24v-26v-26v-26v-26h26v-26v-26h26v-26v-26h-52v26h26v26h-78l-2-24v-26h26v-26h26v-26v-26 h-24v26h-26v-26h24v-26h102v26v24h26v26h26v26h26v26h26v26h-26v26h-26v26h78v26h-26v26v26v26v26h-24v22h24v26h-26v-24h-24V538.1z M538,180h-26v26v26h26v-26V180z M590,256h-26v26h26V256z M640,436.1v-26h-26v26H640z M564,538.1h-26v26h26V538.1z M102,564.1v26h26 v-26H102z M334,384.1v26h-52v26h26v26h-52v-26h-24v-26h-26v26h24v26v26v24v26h-50v26h26v26h-26v26h50v-26v-26h52v-26h-26v-26v-24h26 v24v26h26v-26v-24h52v-26h-26v-26h50v26h26v-26v-26h26v26h26v-26v-26h-52v-24h-50v24H334z M308,590.1h26v-26v-26h-26v26V590.1z M564,564.1v26h26v26h76v-26h26v-26v-26h-26v26H564z M488,590.1v26v26h102v-26h-26v-26h-26v26h-26v-26h26v-26h-76v26H488z M52,616.1 h24v-26H52v-26H26v26v26v26h26V616.1z M102,642.1v-26H76v26H102z M462,642.1v-26h-26v26H462z M898,642.1v-26h-26v26v24h52v-24H898z M950,616.1h-26v26h26V616.1z M128,692.1v-26H52v26H26v26h50v-26H128z M924,692.1h24v26h-24v26h50v-26v-26v-26h-50V692.1z M872,718.1v26h26v-26v-26h-26V718.1z M308,744.1h-26v26h26V744.1z M564,770.1v24h-48v26h-26v26h-26v-26v-26h-26v26h-26v-24h-26v-26 h26v-26h-52v26v24h-26v-26v-26h-26v-24h-26v-26v-24h-50v26v24h24v26h-26v-24h-50v26h26v26h-52v-26v-26h-26v24v26h-26v-26H78v26H26 v-26h50v-26h52v-24h26v-26v-26h-26v-26v-26h26v26h26v26h50v-26h26v-26h52v26h-26v50h26v26v24h26v-26v-24h-26v-24v-26h26v-26h50v-26 v-26v-26v-24h52v24h-26v26h26v-26h26v26v26h-52v26v26h-50v22h52v26h26v26v26h26v-26v-26h52v26h-26v26v26h-26v26h26v26h22v-24h26v-26 h26v-26v-26h52v26h-26v26v26H564z M206,666.1h-26v26h26V666.1z M360,664.1v-22h-26v22H360z M412,692.1h-52v26h52V692.1z M26,794.1 h180v182H26V794.1z M52,950.2h128v-130H52V950.2z M282,794.1h-26v-24h-26v24v26v26h52v-26V794.1z M308,820.1h26v-26h-26V820.1z M820,794.1h-26v26h26V794.1z M924,794.1h24v26h26v-26v-24h-50V794.1z M360,846.1v-26h-26v26H360z M924,846.1v26h24v-26v-26h-24 V846.1z M282,846.1h52v26h46v-26h78v26h-26v26v26h26v-26h26v26h26v-26h-22v-26h26v26h22v26h26v-26h-26v-26h26v-26h26v26v26h52l-2,26 h26v26h-26v26h-78v-26h-26v26h-26v-26H380v-26h26v-26v-26h-22v26h-24v26v24h-26v26h-52v-26v-24h52v-26h-52v26h-52v-26h26v-26h26 V846.1z M590,948.2h26v-26h-26V948.2z M668,846.1h-52v26h52V846.1z M76,872.1v26v26h78v-26v-26v-26H76V872.1z M666,898.1v26h26v-26 H666z M924,898.1v26h50v-26v-26h-26v26H924z M872,974.2h26v-26h-26V974.2z M948,974.2h26v-26h-26V974.2z"/>
	<path d="M589.8,626H410.2c-20.3,0-36.2-15.9-36.2-36.2V410.2c0-20.3,15.9-36.2,36.2-36.2h179.5 c20.3,0,36.2,15.9,36.2,36.2v179.6C626,610.1,610.1,626,589.8,626z"/>
	<path d="M621,587c0,18-14,34-34,34H413c-18,0-34-14-34-34V413c0-18,14-34,34-34h174c18,0,34,14,34,34V587z"/>
	<path d="M434.1,436.4c-2.4-2.9-0.4-7.4,3.3-7.4h124.3c4.6,0,7.4,4.8,3.3,9.4l-32.7,37.4c-3.8,4.4-9.4,6.8-15.1,6.8 h-33.5c-5.8,0-11.3-2.5-15.1-6.8l-4.7-5.4c-0.5-0.5-0.1-1.2,0.4-1.2h35.4c3.1,0,6-1.3,8-3.6l18.1-20.6c0.8-0.9,0.1-2.4-1.1-2.4 h-85.3L434.1,436.4z M482.6,524.1h-12.1v-6h9.4v-6.7h-9.4v-6h10.7v-6.7h-18.8v32.1h20.1V524.1z M509.3,498.7h-21.4v6.7h6.7v25.4h8 v-25.4h6.7V498.7z M437.8,505.4h8.6v14.7c0,2.3-1.7,4-4,4h-8.2l-1.2,6.7h12.1c5.2,0,9.4-4.2,9.4-9.4v-22.8h-15.5L437.8,505.4z M516,505.4h6.7v25.4h8v-25.4h6.7v-6.7H516V505.4z M566.9,530.8h-8l-1.1-5.4h-8.6l-1.1,5.4h-8l8-32.1h10.7L566.9,530.8z M556.5,518.8l-2.9-14.1l-2.9,14.1H556.5z M476.3,554l-1.7,0.5V550h1.7v-4.8h-1.7v-5.5h-4.8v5.5h-2.4v4.8h2.4v6l-2.4,0.7v5.5 l2.4-0.7v4.7h-1.5l-0.9,4.8h7.2v-11l1.7-0.5V554z M488.9,566.3h8.2l-0.8,4.7h-8.3c-2.1,0-4-0.5-5.9-1.5l-1.3-0.7l-0.4,2.1H476 l1.7-9.9h4.3l-0.5,2.8l1.2,0.7c0.4,0.1,0.7,0.4,0.9,0.5V564v-4.6h-5.8V556h6v-1.3v-0.3h-5v-3.2h5v-0.3v-1.2h-5.8v-3.6h5.8v-1.3h-5.8 V541h5.8v-2.1h4.8v2.4h7.2v3.8h-7.2v1.3h6.6v4.8v0.3h1.5v3.2h-1.5v1.5v3.5h-6.6v1.6h6.6v3.8h-6.6v1.5 C488.7,566.3,488.9,566.3,488.9,566.3z M488.7,551.4h2.3v-0.3v-1.3h-2.3v1.3V551.4z M488.7,554.5v0.3v1.5h2.3v-1.5v-0.3H488.7z M511.2,563.9l-0.5-0.4v-12.2h-0.4h-4.6h-2.8v4.6h2.8v5.8l-2.8,9.4h5.1l0.7-2.4l1.6,0.8c1.9,0.9,3.8,1.5,5.9,1.5h16.2l0.9-5.4h-15.9 C514.4,565.6,513.2,565,511.2,563.9z M503.1,541.9l1.7,7h5.2l-1.7-7H503.1z M519.4,538.8v5.1H519h-6v5h4.6l-4.3,14.2h5.6l3.3-11.4 l3.5,11.4h5.6l-4.4-14.2h4.4v-5h-6.8h-0.4v-5.1H519.4z"/>
	<path d="M11.9,1151.6l19.9-8v-30.3H15v-16.8h16.8v-28.7h16.8v28.7h15.1v16.8H48.6v23c4.5-1.9,9-4,13.5-6.2l2.4,16.8 l-15.9,6.7v48.6c0,3.3-0.3,6.6-1,9.9c-0.5,1.7-1.4,3.3-2.4,4.8c-1.6,1.6-3.5,2.8-5.7,3.5c-3.1,0.7-6.2,1-9.3,1H17.8l-3.3-16.4h10.9 c1.2,0.2,2.4,0,3.6-0.3c0.5-0.2,1-0.5,1.6-1c0.5-0.9,0.7-1.7,0.9-2.8c0.2-1.4,0.3-2.8,0.3-4.3V1161c-5.7,2.4-11.2,4.8-16.6,7.4 L11.9,1151.6z M135.8,1079.6v140.8h-17.6v-8H59.6v-17.3h58.5v-42.4h-50v-17.3h50v-38.6H65.3v-17.3H135.8z M349.2,1078.1v16.4h-17.5 c-2.2,10.9-5.4,21.6-9,32h23.5v81.3h-25.8v9.3h-15.2v-53.5c-1.9,3.3-4,6.4-5.9,9.3l-6.9-18.2c5.2-9.7,9.5-19.7,13.1-30.1 c3.6-9.9,6.4-20.1,8.6-30.3h-16.6v-16.4H349.2z M320.5,1191.7h10.2V1143h-10.2V1191.7z M398.4,1171.7v16.3h-49.7v-16.3H398.4z M411.9,1075.5l-5,63.3H421l-2.4,57.1c-0.2,4.7-0.9,9.2-2.1,13.5c-0.7,2.2-1.7,4.5-3.3,6.4c-1.9,2.2-4.3,3.6-7.3,4.5 c-4,0.9-7.8,1.4-11.8,1.4h-18.7l-3.1-16.1h16.4c2.2,0,4.3-0.2,6.4-0.5c1.2-0.3,2.2-0.9,3.1-1.7c1.2-1.2,1.9-2.6,2.2-4.2 c0.5-2.2,0.7-4.7,0.9-7.1c0.7-12.3,1.4-24.7,1.9-37.4h-51.6l4.5-57.3l16.4,1l-2.8,40.3h19.4l4-47.2H353v-16.1H411.9z M614.8,1099.2 c-5.4-8.1-10.6-16.4-15.6-24.7l14.9-9.5c6.4,9.2,12.5,18.3,18.2,27.9l-10,6.4h23.9c8-11.6,15.4-23.5,22.1-35.8l16.1,9.5 c-5.4,9-11.1,17.8-16.8,26.3h27.2v16.6h-44.5v26.3h51.4v17.1h-50.5c4.2,12.3,11.1,22.5,20.9,30.8c5.4,4.3,11.2,8,17.3,11.1 c5.4,2.4,10.7,4.5,16.3,6.2l-8.7,17.5c-13-4.7-24.7-11.4-35.3-20.2c-8.5-7.4-15.2-16.3-20.2-26.5c-5.2,9.2-11.8,17.3-19.5,24.2 c-10.9,9.2-22.7,16.8-35.5,22.8l-9.3-16.8c6.4-2.9,12.8-6.1,18.9-9.5c6.4-3.8,12.3-8.1,17.8-13.1c8.1-7.3,13.5-16.1,16.4-26.5h-49.3 v-17.1h51v-26.3h-44.6v-16.6H614.8z M867.9,1110.3l28.4,24.4l-10.6,14.2l-28-25.3L867.9,1110.3z M860.3,1215.8 c3.6-8.5,6.9-17.3,10-26.1c3.8-10.4,7.4-20.9,10.9-31.5l16.4,6.7c-7.1,19.2-13.8,38.4-20.6,57.6L860.3,1215.8z M941.4,1064.6 c4.3,8.5,8.5,17.1,12.5,25.6l-9.2,4.5h39.6v16.6h-34.9v33.4h30.4v16.6h-30.4v38.6h38.6v16.4h-94.8v-16.4h38.9v-38.6h-29.9v-16.6 h29.9v-33.4h-31.3v-16.4l-9.2,12.6l-26.1-23.2l10-13.3c8.8,7.4,17.5,15.1,26.1,22.7l-0.9,1h36.7c-3.3-7.6-6.7-15.2-10.7-22.7 L941.4,1064.6z"/>
	</svg>
	'''

	var svgGroup = insertSvg(svgCode)
	var pageItems = svgGroup.pageItems
	var textColor = isLight ? '0 0 0 0, #fff' : jettaGrayColor

	// var type = ''
	// for (var index = 0; index < pageItems.length; index++) {
	// 	var element = pageItems[index];
	// 	type += (index + ': ' + element.typename + ' | ')
	// }
	// alert(type)
	// 0: CompoundPathItem | 1: CompoundPathItem | 2: PathItem | 3: PathItem | 4: CompoundPathItem | 5: PathItem |
	pageItems[0].pathItems[0].fillColor = textColor.toAiColor() // text
	pageItems[1].pathItems[0].fillColor = '0 0 0 0, #fff'.toAiColor() // // Logo
	pageItems[2].fillColor = '90 55 0 0, #285aff'.toAiColor() // logo background
	pageItems[3].fillColor = '0 0 0 0, #fff'.toAiColor() // logo background border
	pageItems[4].pathItems[0].fillColor = '0 0 0 100, #000'.toAiColor() // QR
	pageItems[5].fillColor = '0 0 0 0, #fff'.toAiColor() // QR background
	return svgGroup
}

function insertSvg(code, color) {
    var svgFileName = "inlineSVGtoAI.svg";
    var svgFile = new File("" + Folder.temp + "/" + svgFileName);
    svgFile.open("w");

    svgFile.write(code);
    svgFile.close();

    var doc = app.activeDocument;
    var placed = doc.groupItems.createFromFile(svgFile);

    $.sleep(100);
    svgFile.remove();

    return placed
}

// ^^^^^^^^^^^^^^^^^^ Y开始 ^^^^^^^^^^^^^^^^^^ //
Array.prototype.has = function(key) {
	var hasItem = false
	for (var i = 0, len = this.length; i < len; i++) {
		hasItem = hasItem || this[i] === key
	}
	return hasItem
}

var jettaYPoints = [
	[ [ 0, 0 ], [ 0, 0 ], [ 87, -87 ], [ 87, -73.14 ], [ 4.14, 10 ], [ 0, 10 ] ],
	[ [ 0, 19 ], [ 4.14, 19 ], [ 87, 101.86 ], [ 87, 116 ], [ 0, 29 ], [ 0, 29 ] ],
	[ [ 87, -60.08 ], [ 87, -45.94 ], [ 26.51, 14.5 ], [ 87, 74.99 ], [ 87, 89.13 ], [ 12.37, 14.5 ] ]
  ]


//   drawJettaY({
// 	left: 0,
// 	right: 300,
// 	bottom: 0,
// 	bleed: 0,
// 	height: 100,
//	color: '0 0 0 0, #fff',
//   })


  function drawJettaY(param) {
	// var color = app.activeDocument.swatches[4].color
	var newPoints = transformArray(jettaYPoints, param)
	var myShape = createCompoundPath(newPoints)
	myShape.pathItems[0].fillColor = (param.color || '0 95 75 0, #FF143C').toAiColor()
	myShape.pathItems[0].stroked = false
  }

  function transformArray(arr, transform) {
	var newArr = []
	var TAIL_RATIO = 87 / 203 // width / height (px)
	if (!transform) { return arr }
	var height = transform.height || 203
	var left = transform.left
	var right = transform.right
	var bleed = transform.bleed || 0
	var bottom = transform.bottom || 0
	var ratio = height / 203
	for (var i = 0; i < arr.length; i++) {
	  newArr[i] = []
	  for (var j = 0; j < arr[i].length; j++) {
		newArr[i][j] = []
		newArr[i][j][0] = arr[i][j][0] * ratio
		newArr[i][j][1] = arr[i][j][1] * ratio + bottom
		// 计算最做和左右坐标
		var isLeftSidePoints = (i === 0 || i === 1) && (j === 0 || j ===5)
		if (typeof left === 'number' && isLeftSidePoints) {
		  newArr[i][j][0] = left
		} else {
		  newArr[i][j][0] = newArr[i][j][0] + right - height * TAIL_RATIO
		}
		// 计算出血后坐标
		var coordNum = (i + 1) * 10 + j
		var isRightUpPoints = [22, 23, 33, 34].has(coordNum)
		var isRightDownPoints = [12, 13, 30, 31].has(coordNum)
		if (typeof bleed === 'number' && isRightUpPoints) {
		  newArr[i][j][0] = newArr[i][j][0] + bleed
		  newArr[i][j][1] = newArr[i][j][1] + bleed
		}
		if (typeof bleed === 'number' && isRightDownPoints) {
		  newArr[i][j][0] = newArr[i][j][0] + bleed
		  newArr[i][j][1] = newArr[i][j][1] - bleed
		}
	  }
	}
	return newArr
  }

  function createCompoundPath(pointsArr) {
	var doc = app.activeDocument
	var newCompoundPath = doc.activeLayer.compoundPathItems.add()
	// newCompoundPath.wrapInside = true
	for (var i = 0, len = pointsArr.length; i < len; i++) {
	  if (typeof pointsArr[i][0] === 'string') {
		createPathByPoints(newCompoundPath, pointsArr[i])
	  } else {
		var newPath = newCompoundPath.pathItems.add()
		newPath.closed = true
		newPath.evenodd = true
		newPath.setEntirePath(pointsArr[i]);
	  }
	}
	return newCompoundPath
  }

  function createPathByPoints(compoundPath, points) {
	var myLine = compoundPath.pathItems.add()
		myLine.closed = true
		myLine.evenodd = true
	var anchor = points2Anchor(points)
	addPoints(myLine, anchor)
	return myLine
  }


  function points2Anchor(pointsArr) {
	var points = []
	for (var i = 0, len = pointsArr.length; i < len; i++) {
	  var point = {}
	  var coords = pointsArr[i].split(',')
	  point.anchor = [+coords[0], +coords[1]]
	  if (isRealPoint(coords[2], coords[3])) {
		point.leftDirection = [+coords[2], +coords[3]]
	  }
	  if (isRealPoint(coords[4], coords[5])) {
		point.rightDirection = [+coords[4], +coords[5]]
	  }
	  points.push(point)
	}
	return points
  }

  function isRealPoint(x, y) {
	var isXNum = /[-]?\d$/g.test(x)
	var isYNum = /[-]?\d$/g.test(y)
	return  isXNum && isYNum
  }

  function addPoints(line, points) {
	for (var i = 0, len = points.length; i < len; i++) {
	var newPoint = line.pathPoints.add()
		newPoint.anchor = points[i].anchor
		newPoint.leftDirection = points[i].leftDirection ? points[i].leftDirection : points[i].anchor
		newPoint.rightDirection = points[i].rightDirection ? points[i].rightDirection : points[i].anchor
		newPoint.pointType = PointType.CORNER // [CORNER | SMOOTH]
	}
  }


// vvvvvvvvvvvvvvvvvv Y结束 vvvvvvvvvvvvvvvvvv //
